package com.xbang.attendance.web.action.purchase.companygps;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.demo2do.lighturl.annotation.Action;
import com.xbang.attendance.entity.companygps.companyGps;
import com.xbang.attendance.entity.companygps.scope;
import com.xbang.attendance.service.SystemService;
import com.xbang.attendance.utils.MD5;
import com.xbang.core.struts.support.SearchActionSupport;

public class CompanyGpsManager extends SearchActionSupport {
	private Integer id;
	private companyGps user;
	private SystemService systemService;
	private List<scope> departmentList=new ArrayList<scope>();
	public void setSystemService(SystemService systemService) {
		this.systemService = systemService;
	}
	



	public companyGps getUser() {
		return user;
	}




	public void setUser(companyGps user) {
		this.user = user;
	}




	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	@Action("/purchase/companygps/${id}/delete")
	public String delete() throws Exception{
		if(id!=null){
//			String sql="delete from companygps where id='"+id+"'";
			companyGps co=	(companyGps)systemService.getObject(companyGps.class,id);
			systemService.delete(co);
		}
		return "r:/purchase/companygps/list";
	}
	@Action("/purchase/companygps/${id}/edit")
	public String detail() throws Exception {
		user=new companyGps();
		if (id != null) {
			departmentList=systemService.getObjects(scope.class);
			user = (companyGps) systemService.getObject(companyGps.class, id);
		}
		return "detail";
	}
	public List<scope> getDepartmentList() {
		return departmentList;
	}
 

	public void setDepartmentList(List<scope> departmentList) {
		this.departmentList = departmentList;
	}


	@Action("/purchase/companygps/add")
	public String add() throws Exception {
		user=new companyGps();
		departmentList=systemService.getObjects(scope.class);
		return "detail";
	}
	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}
	/*private String departmentId(String name){
		
		return null;
	}*/
	@Action("/purchase/companygps/save")
	public String save() throws Exception {
		if (null !=user) {
			int did=Integer.parseInt(user.getScope());
			user.setScope(did+"");
			systemService.save(user);
			}
		
		return "r:/purchase/companygps/list";
	}
	
	public SystemService getSystemService() {
		return systemService;
	}


	@Action("/purchase/companygps/update")
	public String update() throws Exception {
		systemService.update(user);		
		return "r:/purchase/companygps/list";
	}
}